package com.ruoyi.hualian.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.framework.web.service.EasyExcelConfig;
import com.ruoyi.hualian.domain.*;
import com.ruoyi.hualian.service.ExcelService;
import com.ruoyi.hualian.service.IHlDeliveryTimeService;
import com.ruoyi.hualian.service.IHlFlangeService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.springframework.web.multipart.MultipartFile;


/**
 * 关于 Excel 的接口
 *
 * @author hujian
 */
@Service
public class ExcelServiceImpl implements ExcelService {

    private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);

    @Autowired
    private IHlDeliveryTimeService hlDeliveryTimeService;

    @Autowired
    private IHlFlangeService hlFlangeService;

    /**
     * 根据Excel表返回想要的实体类集合
     */
    @Override
    public <T> List<T> excelObjectList(Class<T> objectClass, String filePath, String fileName, Boolean consolePrinting) {

        // filePath = "D:\\华链-胡健\\2023-12-23ERP系统Excel数据表导入\\";
        // fileName = "商品分类3.xlsx";

        // 文件根路径
        log.info("filePath ==> {}", filePath);
        // 文件名称
        log.info("fileName ==> {}", fileName);
        // 完整的上传文件的路径
        fileName = filePath + File.separator + fileName;
        log.info("完整的上传文件的路径 fileName ==> {}", fileName);
        try {
            FileInputStream fileInputStream = new FileInputStream(new File(fileName));

            List<List<Object>> list = null;

            // 创建Excel工作薄
            Workbook work = null;
            String fileType = fileName.substring(fileName.lastIndexOf("."));
            if (".xls".equals(fileType)) {
                work = new HSSFWorkbook(fileInputStream);
                log.info("2003");
            } else if (".xlsx".equals(fileType)) {
                work = new XSSFWorkbook(fileInputStream);
                log.info("2007");
            } else {
                log.info("解析的文件格式有误！");
                throw new IOException("解析的文件格式有误");
            }
            log.info("创建Excel工作薄成功！");
            if (work == null) {
                throw new IOException("创建Excel工作薄为空！");
            }
            // 页数
            Sheet sheet = null;
            // 行数
            Row row = null;
            // 列数
            Cell cell = null;
            list = new ArrayList<List<Object>>();

            // 遍历 Excel 中所有的 sheet
            for (int i = 0; i < work.getNumberOfSheets(); i++) {

                // 取某个 sheet
                sheet = work.getSheetAt(i);
                if (sheet == null) {
                    continue;
                }

                // 遍历当前 sheet 中的所有行
                for (int j = sheet.getFirstRowNum(); j <= sheet.getLastRowNum(); j++) {

                    row = sheet.getRow(j);
                    if (row == null) {
                        continue;
                    }

                    // 遍历所有的列
                    List<Object> li = new ArrayList<Object>();
                    for (int k = row.getFirstCellNum(); k < row.getLastCellNum(); k++) {

                        cell = row.getCell(k);

                        String value = "";

                        if (null == cell) {
                            li.add(value);
                            continue;
                        }
                        if (Objects.equals(CellType.NUMERIC, cell.getCellType())) {
                            if (DateUtil.isCellDateFormatted(cell)) {
                                // 如果是 date 类型，则获取该 cell 的 date 值
                                Date date = DateUtil.getJavaDate(cell.getNumericCellValue());
                                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                value = format.format(date);
                            } else {
                                // 纯数字
                                double numericCellValue = cell.getNumericCellValue();
                                // BigDecimal big = new BigDecimal(numericCellValue);
                                // value = big.toString();
                                value = String.valueOf(numericCellValue);
                                if (null != value && !"".equals(value.trim())) {
                                    String[] item = value.split("[.]");
                                    // String[] item = value.split("\\.");
                                    if (1 < item.length && "0".equals(item[1])) {
                                        value = item[0];
                                    }
                                }
                            }
                        } else if (Objects.equals(CellType.STRING, cell.getCellType())) {
                            value = cell.getStringCellValue();
                        } else if (Objects.equals(CellType.FORMULA, cell.getCellType())) {
                            // 读公式计算值
                            value = String.valueOf(cell.getNumericCellValue());
                            // 如果获取的数据值为非法值，则转换为获取字符串
                            if (value.equals("NaN")) {
                                value = cell.getStringCellValue();
                            }
                        } else if (Objects.equals(CellType.BOOLEAN, cell.getCellType())) {
                            value = "" + cell.getBooleanCellValue();
                        } else {
                            value = cell.getStringCellValue();
                        }
                        if ("null".endsWith(value.trim())) {
                            value = "";
                        }
                        li.add(value);
                    }
                    list.add(li);
                }
            }

            // [["id","building","area_id","lng","lat","status","remark","created_id","created_by","created_time","updated_id","updated_by","updated_time"],["161","时代美术馆（广州）","0","113.292898","23.22872","1","","","","2022-08-19 15:25:06","","","1900-01-02 00:00:00"]]
            // execl 表的第一行数据。大小是从第1行开始算的。也就是说多了一个对象(对应标题的)

            // 去空

            List<List<Object>> listWithoutEmptySublists = list.stream()
                    .filter(sublist -> !sublist.isEmpty())
                    .collect(Collectors.toList());

            list = listWithoutEmptySublists;

            if (consolePrinting) {
                log.info("list ==> {}", JSON.toJSONString(list));
                log.info("list.size() ==> {}", list.size());
            }

            // 将数据转化成 List<Object> 类型的数据
            // 初始化标题
            List<Object> firstRows = null;
            // 如果转换过来的数据不为空，拿到标题，在之前的方法中判断过是否为空
            if (!list.isEmpty()) {
                firstRows = list.get(0);
            }

            // 初始化实际数据 初始化对象
            List<T> excelDate = new ArrayList<>();
            // 从一开始遍历，为的是拿到数据
            for (int i = 1; i < list.size(); i++) {
                // 每一行实例化一个 List<Object> 数据，后面插入的也是这些
                List<Object> rows = list.get(i);
                T t = objectClass.newInstance();
                // 对 object 的每一个字段进行赋值
                for (int j = 0; j < rows.size(); j++) {
                    // 把 excel 转过来的数据的每个字段的值转换成 String 类型
                    String cellVal = (String) rows.get(j);
                    // excel 表的第一行所代表的标题
                    String fieldName = firstRows.get(j).toString().trim();

                    // 对 object 进行赋值
                    Field[] fields = t.getClass().getDeclaredFields();
                    // 把实体类每个变量遍历一遍
                    for (int k = 0; k < fields.length; k++) {
                        // 拿到一个对象
                        Field field = fields[k];
                        // 可以访问私有
                        field.setAccessible(true);
                        // 判断excel注解修饰
                        Excel excel = field.getAnnotation(Excel.class);
                        if (excel == null) {
                            log.warn("上传失败，实体类无@Excel(name = ''修饰”)");
                            throw new RuntimeException("上传失败，实体类无@Excel(name = ''修饰”)");
                            // continue;
                        }
                        // 每个实体类 Long id 处理
                        boolean id = excel.name().contains("id");
                        if (k == 0 && id) {
                            continue;
                        }
                        // 如果 excel 转化过来的标题名和实体类字段或者实体类注解相同，说明对应上了。可以进行赋值
                        if (fieldName.equals(excel.name()) || fieldName.equals(field.getName())) {
                            // 取得类型,并根据对象类型设置值.
                            // 将 excel 中得 String 类型的数值，转化成对应实体类属性，把属性值 set 进对象
                            if (field.getType() == Integer.class) {
                                field.set(t, Integer.valueOf(cellVal));
                            } else if (field.getType() == Long.class) {
                                field.set(t, Long.valueOf(cellVal));
                            } else if (field.getType() == Double.class) {
                                field.set(t, Double.valueOf(cellVal));
                            } else if (field.getType() == LocalDateTime.class) {
                                DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                                LocalDateTime time = LocalDateTime.parse(cellVal, df);
                                field.set(t, time);
                            } else if (field.getType() == BigDecimal.class) {
                                if (ObjectUtils.isNotEmpty(cellVal)) {
                                    field.set(t, new BigDecimal(cellVal));
                                }
                            } else if (field.getType() == Date.class) {
                                log.info("cellVal ==> {}", cellVal);
                                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                Date parse = format.parse(cellVal);
                                field.set(t, parse);
                            } else {
                                field.set(t, cellVal);
                            }
                        }
                    }
                }
                excelDate.add(t);
            }

            // 注意：实体类要有set方法
            if (consolePrinting) {
                log.info("最后转化成实体类的数组excelDate的大小 ==> {}", excelDate.size());
                log.info("最后转化成实体类的数组excelDate ==> {}", JSON.toJSONString(excelDate));
            }
            return excelDate;
        } catch (IOException e) {
            log.warn("上传失败，报错信息 ==> {}", e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            log.warn("上传失败，报错信息 ==> {}", e);
            throw new RuntimeException(e);
        } catch (ParseException e) {
            log.warn("上传失败，报错信息 ==> {}", e);
            throw new RuntimeException(e);
        }
        return null;
    }

    /**
     * Excel表对应的List对象集合
     */
    @Override
    public <T> List<T> read(MultipartFile file, Class<T> objectClass) throws Exception {
        T t = objectClass.newInstance();
        EasyExcelConfig<T> easyExcelConfig = new EasyExcelConfig<T>();

        EasyExcel.read(file.getInputStream(), objectClass, easyExcelConfig)
                .sheet()  //excel中表的名称，默认为第一个sheet
                .doRead();
        ;
        return easyExcelConfig.getData();
        // 将读取到的数据存入数据库中
        // data.forEach(it-> usersMapper.insert(it));
    }

    /**
     * 根据List集合下载Excel文件
     */
    @Override
    public <T> String wired(List<T> list, Class<T> objectClass, String excelName, HttpServletResponse response) throws Exception {
        // 1、设置响应头和其他信息
        // 设置响应的 MIME 类型为 "application/vnd.ms-excel"，表示响应内容为 Excel 文件。
        response.setContentType("application/vnd.ms-excel");
        // 设置响应的字符编码为 UTF-8，以确保中文等特殊字符能正确显示。
        response.setCharacterEncoding("utf-8");
        // 这里的URLEncoder.encode()可以防止中文乱码，（这里有异常，直接抛出）
        String fileName = URLEncoder.encode(excelName, "UTF-8");
        // 设置响应头信息Content-disposition(这表示以下载方式打开文件),它告诉客户端浏览器以
        //下载方式处理响应内容，并指定下载的文件名为 "分类数据.xlsx"（通过拼接上文件名和扩展名）
        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
        // 3、调用EasyExcel的wired方法完成写操作
        EasyExcel.write(response.getOutputStream(),
                objectClass).sheet(excelName).doWrite(list);
        log.info("下载成功");
        return "下载成功";
    }

    /**
     * 绿灯率
     */
    @Override
    public String green(String greenFilePath, String greenFileName, String summaryFilePath, String summaryFileName, HttpServletResponse response) throws Exception {

        List<Green> greenList = excelObjectList(Green.class, greenFilePath, greenFileName, false);

        List<Summary> summaryList = excelObjectList(Summary.class, summaryFilePath, summaryFileName, false);

        List<Green> greens = greenList.stream()
                .filter(green -> "nc M A09".equals(green.getProductionEquipment()))
                .collect(Collectors.toList());

        log.info("nc M A09 报工明细 ==> {}", JSON.toJSONString(greens));

        Map<String, List<Summary>> map = new HashMap<>();
        List<Summary> ncMA0 = new ArrayList<>();

        String prefixString = "ncMA0";
        int prefixInteger = -1;

        Summary lastSummary = new Summary();
        lastSummary.setDuration("持续时长(分钟)");
        summaryList.add(lastSummary);

        for (int i = 0; i < summaryList.size(); i++) {
            Summary summary = summaryList.get(i);
            String duration = summary.getDuration();
            ncMA0.add(summary);
            if ("持续时长(分钟)".equals(duration)) {
                prefixInteger = prefixInteger + 2;
                map.put(prefixString + prefixInteger, ncMA0);
                ncMA0 = new ArrayList<>();
            }
        }

        // 创建时间格式器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        List<Summary> ncMA09SummaryList = map.get("ncMA09");
        for (int i = 0; i < greens.size(); i++) {
            Green green = greens.get(i);

            String startTimeStr = green.getStartTime();
            String endTimeStr = green.getEndTime();
            // 解析时间为 LocalDateTime 对象
            LocalDateTime startTime = LocalDateTime.parse(startTimeStr + ":00", formatter);
            LocalDateTime endTime = LocalDateTime.parse(endTimeStr + ":00", formatter);

            for (int ii = 0; ii < ncMA09SummaryList.size(); ii++) {
                Summary summary = ncMA09SummaryList.get(ii);
                String checkTimeStr = summary.getTime();
                if (ObjectUtils.isEmpty(checkTimeStr)) {
                    continue;
                }
                LocalDateTime checkTime = LocalDateTime.parse(checkTimeStr, formatter);

                // 判断检查时间是否在工作时间内
                boolean isWithinWorkingHours = checkTime.isAfter(startTime) && checkTime.isBefore(endTime);
                if (isWithinWorkingHours) {
                    ncMA09SummaryList.get(ii).setWorkOrder(green.getWorkOrder());
                    ncMA09SummaryList.get(ii).setProductionProcesses(green.getProductionProcesses());
                    ncMA09SummaryList.get(ii).setProductionTaskNumber(green.getProductionTaskNumber());
                    ncMA09SummaryList.get(ii).setProduct(green.getProduct());
                    ncMA09SummaryList.get(ii).setProductionEquipment(green.getProductionEquipment());
                    ncMA09SummaryList.get(ii).setJobApplicants(green.getJobApplicants());
                }
            }
        }

        return wired(ncMA09SummaryList, Summary.class, "ncMA09", response);
    }

    /**
     * 货期数据导入数据库
     */
    @Override
    public AjaxResult deliveryTime(String filePath, String fileName, HttpServletResponse response) {

        List<HlDeliveryTime> hlDeliveryTimeList = excelObjectList(HlDeliveryTime.class, filePath, fileName, false);

        List<HlDeliveryTime> hlDeliveryTimes = new ArrayList<>();
        for (int i = 0; i < hlDeliveryTimeList.size(); i++) {
            HlDeliveryTime hlDeliveryTime = hlDeliveryTimeList.get(i);

            HlDeliveryTime deliveryTime = new HlDeliveryTime();
            String type = hlDeliveryTime.getType();
            String detailsType = hlDeliveryTime.getDetailsType();

            if (ObjectUtils.isNotEmpty(detailsType)) {
                String[] split = detailsType.split("-");
                for (String s : split) {
                    deliveryTime.setType(type);
                    deliveryTime.setDetailsType(s);
                    deliveryTime.setBasicProcessingDay(hlDeliveryTime.getBasicProcessingDay());
                    deliveryTime.setIsSemiFinishedProducts("0");
                    if (ObjectUtils.isNotEmpty(hlDeliveryTime.getNoHoleModification())) {
                        deliveryTime.setNoHoleModification(hlDeliveryTime.getNoHoleModification());
                    }
                    deliveryTime.setAlreadyHobbing(hlDeliveryTime.getAlreadyHobbing());
                    deliveryTime.setAlreadyCar(hlDeliveryTime.getAlreadyCar());
                    deliveryTime.setReserveMaterials(hlDeliveryTime.getReserveMaterials());
                    deliveryTime.setVeryMaterials(hlDeliveryTime.getVeryMaterials());
                    deliveryTime.setOrderingMaterials(hlDeliveryTime.getOrderingMaterials());
                    hlDeliveryTimes.add(deliveryTime);
                }
            } else {
                // 光面惰轮
                deliveryTime.setType(type);
                deliveryTime.setBasicProcessingDay(hlDeliveryTime.getBasicProcessingDay());
                deliveryTime.setIsSemiFinishedProducts("0");
                deliveryTime.setNoHoleModification(hlDeliveryTime.getNoHoleModification());
                deliveryTime.setAlreadyHobbing(hlDeliveryTime.getAlreadyHobbing());
                deliveryTime.setAlreadyCar(hlDeliveryTime.getAlreadyCar());
                deliveryTime.setReserveMaterials(hlDeliveryTime.getReserveMaterials());
                deliveryTime.setVeryMaterials(hlDeliveryTime.getVeryMaterials());
                deliveryTime.setOrderingMaterials(hlDeliveryTime.getOrderingMaterials());
                hlDeliveryTimes.add(deliveryTime);
            }
        }

        hlDeliveryTimeService.insertList(hlDeliveryTimes);
        return AjaxResult.success();
    }

    /**
     * 中机昌盛-华刚资料整理
     */
    @Override
    public String zhongJiChangShengHuaGang(HttpServletResponse response) throws Exception {

        String ZJTypePriceFilePath = "D:\\华链-胡健\\2024-05-07中机昌盛数据处理\\idea所需数据\\";
        String ZJTypePriceFileName = "型号对应和价格表.xlsx";
        List<ZJTypePrice> zjTypePriceList = excelObjectList(ZJTypePrice.class, ZJTypePriceFilePath, ZJTypePriceFileName, false);

        String ZJTitleFilePath = "D:\\华链-胡健\\2024-05-07中机昌盛数据处理\\idea所需数据\\";
        String ZJTitleFileName = "轴承座组件-分类-标题信息.xlsx";
        List<ZJTitle> zjTitleList = excelObjectList(ZJTitle.class, ZJTitleFilePath, ZJTitleFileName, false);

        List<ZJProduct> zjProductList = new ArrayList<>();
        for (int i = 0; i < zjTypePriceList.size(); i++) {
            ZJProduct zjProduct = new ZJProduct();

            ZJTypePrice zjTypePrice = zjTypePriceList.get(i);
            String huaLianType = zjTypePrice.getHuaLianType();

            Pattern pattern = Pattern.compile("[a-zA-Z ]+");
            Matcher matcher = pattern.matcher(huaLianType);
            StringBuffer output = new StringBuffer();
            while (matcher.find()) {
                output.append(matcher.group());
            }

            for (int ii = 0; ii < zjTitleList.size(); ii++) {
                if (output.toString().equals(zjTitleList.get(ii).getTypeSx())) {
                    StringBuffer productCode = new StringBuffer();
                    productCode.append(huaLianType);
                    if (ObjectUtils.isNotEmpty(zjTypePrice.getMiSiMiType())) {
                        productCode.append("=").append(zjTypePrice.getMiSiMiType());
                    }
                    if (ObjectUtils.isNotEmpty(zjTypePrice.getYiHeDaType())) {
                        productCode.append("=").append(zjTypePrice.getYiHeDaType());
                    }
                    if (ObjectUtils.isNotEmpty(zjTypePrice.getAiAnTeType())) {
                        productCode.append("=").append(zjTypePrice.getAiAnTeType());
                    }

                    zjProduct.setProductCode(productCode.toString());
                    zjProduct.setCommodityTitle(zjTitleList.get(ii).getCommodityTitle());
                    zjProduct.setPrice(new BigDecimal(zjTypePrice.getPrice()).setScale(2, RoundingMode.HALF_UP).toString());
                    zjProduct.setInventory("100");
                    zjProduct.setPrimaryClassification(zjTitleList.get(ii).getPrimaryClassification());
                    zjProduct.setSecondaryClassification(zjTitleList.get(ii).getSecondaryClassification());
                    zjProductList.add(zjProduct);
                    break;
                }
            }
        }
        return wired(zjProductList, ZJProduct.class, "中机昌盛华钢轴承座组件数据", response);
    }

    /**
     * 法兰 FC 统计数据
     */
    @Override
    public String fcStatistics(String filePath, String fileName, HttpServletResponse response) throws Exception {

        List<FCStatistics> fcStatisticsList = excelObjectList(FCStatistics.class, filePath, fileName, false);

        HashMap<String, Integer> hashMap = new HashMap<>();

        for (FCStatistics fcStatistics : fcStatisticsList) {
            String huaLianType = fcStatistics.getHuaLianType();
            String[] split = huaLianType.split("-");
            for (String s : split) {
                if (s.contains("FC") && !s.contains("QFC")) {
                    Integer integer = hashMap.get(s);
                    if (ObjectUtils.isEmpty(integer)) {
                        hashMap.put(s, Integer.valueOf(fcStatistics.getNum()));
                    } else {
                        hashMap.put(s, Integer.valueOf(fcStatistics.getNum()) + integer);
                    }
                }
            }
        }

        List<FCStatistics> fcStatistics = new ArrayList<>();

        HlFlange hlFlange = new HlFlange();
        List<HlFlange> hlFlangeList = hlFlangeService.selectHlFlangeList(hlFlange);
        // 使用entrySet()和增强for循环遍历
        for (Map.Entry<String, Integer> entry : hashMap.entrySet()) {
            FCStatistics fc = new FCStatistics();
            String key = entry.getKey();
            Integer value = entry.getValue();

            log.info("key ==> {}", key);
            BigDecimal tpFBigDecimal = new BigDecimal(key.substring(2));
            // 向下取整
            tpFBigDecimal = tpFBigDecimal.setScale(0, RoundingMode.DOWN);
            BigDecimal finalTpFBigDecimal = tpFBigDecimal;
            List<HlFlange> extractHlFlangeList = hlFlangeList.stream()
                    .filter(flange -> flange.getFlangeOutsideDiameter().equals(finalTpFBigDecimal.toString()))
                    .collect(Collectors.toList());
            if (ObjectUtils.isNotEmpty(extractHlFlangeList)) {
                if (extractHlFlangeList.size() == 1) {
                    fc.setHuaLianType(key + " × " + extractHlFlangeList.get(0).getFlangeInsideDiametere());
                } else {
                    // 排序，内径大的放前面
                    extractHlFlangeList.sort((s1, s2) -> Double.compare(Double.parseDouble(s2.getFlangeInsideDiametere()), Double.parseDouble(s1.getFlangeInsideDiametere())));
                    fc.setHuaLianType(key + " × " + extractHlFlangeList.get(0).getFlangeInsideDiametere());
                }
            } else {
                fc.setHuaLianType(key);
            }
            fc.setNum(value.toString());
            fcStatistics.add(fc);
        }
        return wired(fcStatistics, FCStatistics.class, "FC法兰数据", response);
    }

    /**
     * ERP价格梯度-个性导入
     */
    @Override
    public String priceGradient(String filePath, String fileName, HttpServletResponse response) throws Exception {

        PriceGradient a = new PriceGradient();
        a.setA("商品价格梯度更新");

        PriceGradient b = new PriceGradient(
                "商品编码",
                "商品名称",
                "型号",
                "规格",
                "品牌",
                "经销商价(1-19)",
                "经销商价(20-49)",
                "经销商价(50-99)",
                "经销商价(100-499)",
                "零售价(1-19)",
                "零售价(20-49)",
                "零售价(50-99)",
                "零售价(100-499)",
                "无备货价(1-19)",
                "无备货价(20-49)",
                "标准价(1-19)",
                "标准价(20-49)",
                "标准价(50-99)",
                "标准价(100-499)",
                "标准价(500-999)",
                "标准价(1000-9999)",
                "参考成本价(1-9999)"
        );

        List<PriceGradient> priceGradientList = excelObjectList(PriceGradient.class, filePath, fileName, false);

        List<PriceGradient> priceGradients = new ArrayList<>();
        for (int i = 0; i < priceGradientList.size(); i++) {
            priceGradients.add(priceGradientList.get(i));
            // 检查是否已经处理了40个"我"
            if ((i + 1) % 40 == 0) {
                priceGradients.add(a);
                priceGradients.add(b);
            }
        }
        return wired(priceGradients, PriceGradient.class, "ERP价格梯度个性导入数据", response);
    }
}
